<template>
  <!-- <div>
      <el-row
    v-for="item in data"
    :key="item.id"
    type="flex"
    class="content"
    @click.native="categoryDetailList(item.id)"
  >
    <el-col :span="8">
      <el-row type="flex" class="content-img" justify="center" align="middle"
        ><img :src="item.image" alt=""
      /></el-row>
    </el-col>
    <el-col>
      <div class="borders">
        <el-row type="flex" justify="center" class="title">{{ item.title || item.name }}</el-row>
        <el-row>{{ item.desc }}</el-row>
      </div>
    </el-col>
  </el-row>
    </div> -->
  <div class="demo">
    <el-row class="row11"  >
      <el-col class="col" v-for="item in data" :key="item.id" @click.native="categoryDetailList(item.id)"
  >
        <div class="imgs"><img :src="item.image" alt="" /></div>
        <div class="item1">
          <h4>{{ item.title || item.name }}</h4>
          <p class="desc">{{ item.desc }}</p>
          <p class="date">{{ item.created_at | toDate }}发售</p>
          <div class="after"><i class="el-icon-mouse"></i></div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Array,
    },
    route: {
      required: true,
    },
    category: {
      required: true,
    },
  },
  filters: {
    toDate(val) {
      let year = new Date(val).getFullYear();
      let month = new Date(val).getMonth() + 1;
      let day = new Date(val).getDay();
      return `${year}年${month}月${day}日`;
    },
  },
  methods: {
    // 点击跳转路由 并在路由带上参数
    categoryDetailList(id) {
      let query = {};
      query[this.category] = id;
      this.$router.push({
        path: this.route,
        query,
      });
    },
  },
};
</script>

<style lang="less" >
.demo {
  .row11{
    display: flex;
    justify-content: space-around;
     flex-wrap: wrap;
  }
  .col {
    margin-top: 25px;
    position: relative;
    width: 350px;
    height: 370px;
    background-color: #ffffff;
    // box-shadow: 1px 3px 17px 0px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    &:hover {
      box-shadow: 1px 3px 17px 0px;
      .imgs {
        overflow: hidden; 
      }
      img {
        transform: scale(1.2);
        transition: all 2s ease-out;
      }
    }
    .desc {
      overflow: hidden; //超出文本隐藏

      text-overflow: ellipsis; //溢出省略号显示

      display: -webkit-box; //将对象作为弹性伸缩盒子

      -webkit-box-orient: vertical; //设置伸缩盒子的子元素排列方式-从上到下垂直排列

      -webkit-line-clamp: 3;
    }
    .date {
      position: absolute;
      bottom: 0;
    }
    .after {
      position: absolute;
      right: 0;
      bottom: 0;
      background-color: #e86fd0;
      height: 40px;
      width: 45px;
      border-top-left-radius: 22px;
      text-align: center;
      .el-icon-mouse {
        line-height: 45px;
        font-size: 20px;
        color: #fff;
      }
    }

    .item1 {
      position: absolute;
      padding: 20px 0 10px 20px;
      left: 26px;
      bottom: 0px;
      width: 60%;
      height: 200px;
      background-color: #ffffff;
      h4 {
        margin-bottom: 10px;
      }
      p {
        line-height: 30px;
        color: #878787;
        font-size: 14px;
      }
    }
  }
  .imgs {
    width: 100%;
    height: 250px;
  }
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}
.classify {
  width: 1200px;
  margin: 0 auto;
}
.content {
  margin-top: 15px;
  height: 150px;
  border: 1px solid #666;
  cursor: pointer;

  img {
    cursor: pointer;
    width: 140px;
    height: 140px;
    line-height: 150px;
    object-fit: cover;
  }
  .title {
    margin-bottom: 10px;
  }
  .images {
    width: 100%;
    height: 100%;
  }
  .content-img {
    height: 100%;
  }
  .borders {
    border-left: 1px solid #666;
    padding-left: 5px;
    margin: 5px 0 5px 0;
    height: 90%;
  }
}
</style>
